1. Tips: 省略屬性名稱

當物件的屬性與函式/變數名稱相同時,可以省略不寫 !!!

// 原本的寫法
const view = {
  displayCards: function displayCards() { ...  }
}
// 省略後的寫法
const view = {
  displayCards() { ...  }
}

2. 解構賦值 destructuring assignment

let [a, b, c] = [1, 2, 3]
只要等號兩邊的模式相同 (例如都是 [] 或都是 {}),左邊的變數就會被賦予右邊的對應值。


#省略屬性名稱 #解構賦值 destructuring assignment







Related Posts

《鳥哥 Linux 私房菜:基礎篇》Chapter 04 - 首次登入與線上求助

《鳥哥 Linux 私房菜:基礎篇》Chapter 04 - 首次登入與線上求助

單元測試的藝術, 2/e (The Art of Unit Testing: with examples in C#,  2/e)

單元測試的藝術, 2/e (The Art of Unit Testing: with examples in C#, 2/e)

現代前端工具

現代前端工具


Comments